//
//  ICContactsDetailHeaderView.m
//  ICome
//
//  Created by Administrator on 2017/4/12.
//  Copyright © 2017年 iCom. All rights reserved.
//

#import "ICContactsDetailHeaderView.h"
#import "ICHeaderFile.h"

@interface ICContactsDetailHeaderView()

-(void)buildViews;

@end

@implementation ICContactsDetailHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self buildViews];
        [self setConstraint];
        
    }
    return self;
}

-(void)buildViews
{
    [self addSubview:self.bgImageView];
    [self addSubview:self.headImageView];
    [self addSubview:self.titleLabel];
    [self addSubview:self.jobLabel];
    [self addSubview:self.nameLabel];
    
    [self addSubview:self.sendIMButton];
//    [self addSubview:self.discoverButton];
//    [self addSubview:self.videoCallButton];
}


-(void)setConstraint
{
    [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top);
        make.centerX.equalTo(self.mas_centerX);
        make.width.mas_equalTo(self.width);
        make.height.mas_equalTo(self.height);
    }];
    
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(App_Frame_Width/375.0f * (10));
        make.left.equalTo(self.mas_left).offset(App_Frame_Width/375.0f * (15));
        make.width.mas_equalTo(App_Frame_Width/375.0f * (50));
        make.height.mas_equalTo(App_Frame_Width/375.0f * (50));
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headImageView.mas_right).offset(App_Frame_Width/375.0f * (10));
        make.top.equalTo(self.headImageView.mas_top).offset(5);
    }];
    
    [self.nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headImageView.mas_centerY).offset(5);
        make.left.equalTo(self.titleLabel.mas_left);
        make.right.equalTo(self.sendIMButton.mas_right).offset(-5);
    }];
    
    [self.jobLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headImageView.mas_right).offset(App_Frame_Width/375.0f * (10));
        make.bottom.equalTo(self.headImageView.mas_bottom);
    }];

    [self.sendIMButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.headImageView.mas_bottom);
        make.right.equalTo(self.mas_right).offset(-15);
        make.width.mas_equalTo(App_Frame_Width/375.0f * (60));
        make.height.mas_equalTo(App_Frame_Width/375.0f * (34));
    }];
    
//    [self.videoCallButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.mas_top).offset(App_Frame_Width/375.0f * (136.5));
//        make.left.equalTo(self.sendIMButton.mas_right).offset(App_Frame_Width/375.0f * (25));
//        make.width.mas_equalTo(App_Frame_Width/375.0f * (55));
//        make.height.mas_equalTo(App_Frame_Width/375.0f * (60));
//    }];
    
//    [self.discoverButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.mas_top).offset(App_Frame_Width/375.0f * (136.5));
//        make.right.equalTo(self.mas_right).offset(App_Frame_Width/375.0f * (-80));
//        make.width.mas_equalTo(App_Frame_Width/375.0f * (55));
//        make.height.mas_equalTo(App_Frame_Width/375.0f * (60));
//    }];
    self.headImageView.layer.masksToBounds = YES;
//    self.headImageView.layer.cornerRadius = App_Frame_Width/375.0f * (70)*0.5;
    self.headImageView.layer.cornerRadius = 5.0;
//    self.headImageView.layer.borderColor = ICRGB(0xf9f7f7).CGColor;
    
    [ICTools drawLineWithSuperView:self
                             Color:LINEBACKGROUNDCOLOR
                             Frame:CGRectMake(0,self.frame.size.height - 0.5,App_Frame_Width,0.5)];


}


-(UIImageView *)bgImageView
{
    if(!_bgImageView)
    {
        _bgImageView = [[UIImageView alloc]init];
        _bgImageView.backgroundColor = NE_BACKGROUND_COLOR;
    }
    return _bgImageView;
}

-(UIImageView *)headImageView
{
    if(!_headImageView)
    {
        _headImageView = [[UIImageView alloc]init];
        _headImageView.userInteractionEnabled = YES;
        //_headImageView.backgroundColor = [UIColor grayColor];
    }
    return _headImageView;
}
-(UILabel *)titleLabel
{
    if(!_titleLabel)
    {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.textColor = ICRGB(0xffffff);
        _titleLabel.font = [UIFont systemFontOfSize:17];
    }
    return _titleLabel;
}

-(UILabel *)jobLabel {
    if(!_jobLabel)
    {
        _jobLabel = [[UILabel alloc]init];
        _jobLabel.textAlignment = NSTextAlignmentLeft;
        _jobLabel.textColor = ICRGB(0xffffff);
        _jobLabel.font = [UIFont systemFontOfSize:13];
    }
    return _jobLabel;
}

-(UILabel *)nameLabel {
    if(!_nameLabel)
    {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.textColor = ICRGB(0xffffff);
        _nameLabel.font = [UIFont systemFontOfSize:13];
    }
    return _nameLabel;
}

-(UIButton *)sendIMButton
{
    if(!_sendIMButton)
    {
        _sendIMButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, App_Frame_Width/375.0f * (55), App_Frame_Width/375.0f * (60))];
        [_sendIMButton setTitle:@"发消息" forState:UIControlStateNormal];
        _sendIMButton.layer.cornerRadius = 5;
        _sendIMButton.layer.masksToBounds = YES;
        _sendIMButton.layer.borderColor = [UIColor whiteColor].CGColor;
        _sendIMButton.layer.borderWidth = 1;
        _sendIMButton.titleLabel.font = [UIFont systemFontOfSize:13];
    }
    return _sendIMButton;
}


//-(UIButton *)sendIMButton
//{
//    if(!_sendIMButton)
//    {
//        _sendIMButton = [[ICUserinfoButton alloc]initWithFrame:CGRectMake(0, 0, App_Frame_Width/375.0f * (55), App_Frame_Width/375.0f * (60))];
//        [_sendIMButton setTitle:@"发消息" forState:UIControlStateNormal];
//    }
//    return _sendIMButton;
//}
//
//-(UIButton *)discoverButton
//{
//    if(!_discoverButton)
//    {
//        _discoverButton = [[ICUserinfoButton alloc]initWithFrame:CGRectMake(0, 0,App_Frame_Width/375.0f * (55), App_Frame_Width/375.0f * (60))];
//        [_discoverButton setTitle:NSLocalizedString(@"dynamic", nil) forState:UIControlStateNormal];
//    }
//    return _discoverButton;
//}
//
//-(UIButton *)videoCallButton
//{
//    if(!_videoCallButton)
//    {
//        _videoCallButton = [[ICUserinfoButton alloc]initWithFrame:CGRectMake(0, 0,App_Frame_Width/375.0f * (55), App_Frame_Width/375.0f * (60))];
//        [_videoCallButton setTitle:NSLocalizedString(@"video", nil) forState:UIControlStateNormal];
//    }
//    return _videoCallButton;
//}




@end
